package expression;

/**
 * 减法算式子类 - 实验内容2
 * 编写减法算式子类
 */
public class SubExpression extends Expression {
    public SubExpression(int left, int right) {
        super(left, right);
        // 确保被减数不小于减数
        if (left < right) {
            this.left = right;
            this.right = left;
        }
    }
    
    @Override
    public int calculate() {
        return left - right;
    }
    
    @Override
    public String getOperator() {
        return "-";
    }
}